{extend name="public/base"}

{block name="title"}
申请售后
{/block}

{block name="style"}
{css href="/static/wechat/css/refund.css" /}
{/block}

{block name="body"}

<div class="pageControl orderDetails">
    <div class="msui_nav msui_navTop" style="border-bottom: 1px solid #cccccc;">
        <a class="msui_navTop-back" href="javascript:history.back();"><i class="micon-back"></i></a>
        <h1 class="msui_navTop-title">申请售后</h1>
    </div>
    <div class="weui-top">
        {if condition="$code eq 400150"}
        <p class="error_text">产品正在售后中</p>
        {elseif condition="$code eq 400057"}
        <p class="error_text">订单状态异常</p>
        {elseif condition="$code eq 400149"}
        <p class="error_text">售后时间已过期<br />你已经不能发起售后</p>
        {else /}
        <form action="{:url('save_austin')}" method="post" id="austin_form" class="iptform">
            <!--单选列表-->
            <div class="weui-cells server_type">
                <div class="weui-cell">
                    <div class="weui-cell__bd">
                        <p class="refundreason">服务类型</p>
                    </div>
                    <div class="weui-cell__ft">&nbsp;</div>
                </div>
                <div class="demos-content-padded">
                    {eq name="audit_type" value="1"}
                    <div class="button_sp_area">
                        <a href="javascript:;" data-server-type="1" class="weui-btn weui-btn_mini weui-btn_default server_type_action">退款</a>
                        <a href="javascript:;" data-server-type="2" class="weui-btn weui-btn_mini weui-btn_default">换货</a>
                        <a href="javascript:;" data-server-type="3" class="weui-btn weui-btn_mini weui-btn_default">维修</a>
                    </div>
                    {else /}
                    <div class="button_sp_area">
                        <a href="javascript:;" data-server-type="2" class="weui-btn weui-btn_mini weui-btn_default server_type_action">换货</a>
                        <a href="javascript:;" data-server-type="3" class="weui-btn weui-btn_mini weui-btn_default">维修</a>
                    </div>
                    {/eq}
                </div>
            </div>
            {eq name="audit_type" value="1"}
            <div class="weui-cells return-money">
                <div class="weui-cell">
                    <div class="weui-cell__bd">
                        <p class="fs08">退款金额(元)</p>
                    </div>
                    <input type="number" name="return_money" data-max-money="{$product.product_price * $product.product_num - $coupon_price}" value="{$product.product_price * $product.product_num - $coupon_price}" style="border: none; text-align: right;">
                    {gt name="coupon_price" value="0"}
                    <p>订单使用优惠券，本产品优惠金额{$coupon_price}</p>
                    {/gt}
                </div>
                <p class="referrer" style=" background: #fff; text-align: right; color: red; font-size: .7rem; padding-right: 15px; display:none;"></p>
            </div>
            {/eq}

            <!--用户退款输入详细原因-->
            <span class="cause">输入详细的原因</span>
            <textarea name="msg"></textarea>

            <div class="weui-cells weui-cells_form" style="margin: 0rem;">
                <div class="weui-uploader__input-box">
                    <input id="uploaderInput" class="weui-uploader__input" type="file" accept="image/*"  multiple="multiple" />
                </div>
                <span class="imgnub  fs07">最多三张</span>
            </div>

            <!--服务单售后申请-->
            <input type="hidden" name="type" value="2">
            <!--申请提款-->
            <input type="hidden" name="audit_type" value="{$audit_type}">
            <input type="hidden" name="obj_id" value="{$product.repair_id}">
            <input type="hidden" name="img1" value="">
            <input type="hidden" name="img2" value="">
            <input type="hidden" name="img3" value="">
            <input type="hidden" name="order_id" value="{$product.order_id}">
            <input type="hidden" name="product_id" value="{$product.id}">
            <!--提交按钮-->
            <button class="tijiao fs085" type="submit">提交</button>
        </form>
        {/if}
    </div>
</div>
<div id="loadingToast" style="display:none;">
    <div class="weui-mask_transparent"></div>
    <div class="weui-toast">
        <i class="weui-loading weui-icon_toast"></i>
        <p class="weui-toast__content">数据加载中</p>
    </div>
</div>
{/block}

{block name="javascript"}
{js href="/static/wechat/js/refund.js" /}
<script>
    $(function () {
        $("#uploaderInput").change(function(){
            $("#loadingToast").show();
            window.setTimeout(function(){
                upload_image('{:url("Base/get_upload_img")}', 'austin', 2);
            },666);
        });
    });
    $("#austin_form").submit(function (e) {
        e.preventDefault();
        var _this = $(this);
        $.ajax({
            type : 'POST',
            url : _this.attr('action'),
            data : _this.serialize(),
            dataType : 'json',
            success : function (msg) {
                if (msg.code == 200) {
                    alert('申请成功！');
                    window.location.href = '{:url("austin/index")}';
                } else {
                    var code = msg.code;
                    $.alert(error_code[code]);
                }
            }
        });
    });
</script>
{/block}